#include <iostream>
using namespace std;

class Node
{
public:
	Node():next(NULL) {}
	Node(int d)
	{
		data = d;
		next = NULL;
	}

	int data;
	Node* next;

};

class LinkList
{
public:
	LinkList():head(NULL) {}
	LinkList(Node* pt)
	{
		head = pt;
	}
	void appendToTail(int d)
	{
		if(head)
		{
			Node* pt = head;
			while(pt -> next)
			{
				pt = pt->next;
			}
			Node* newnode = new Node(d);
			pt->next = newnode;
		}
		else
		{
			head = new Node(d);
		}
	}

	Node* at(int k)
	{
		if(k <= 0)
			return NULL;
		if(!head) return NULL;
		Node* pt = head;
		int count = 1;
		while(count < k)
		{
			if(pt->next)
			{
				pt = pt->next;
				count++;
			}
			else
			{
				return NULL;
			}
		}
		return pt;
	}

	void print()
	{
		Node* pt = head;
		while(pt)
		{
			cout << pt->data << endl;
			pt = pt->next;
		}

	}

	Node* head;
};